package com.besmart.workflow.core.model.util;

import com.besmart.workflow.core.model.ConditionNode;
import com.besmart.workflow.core.model.OperationDescriptor;
import com.besmart.workflow.core.model.OperationNode;

public class OperationNodeCreator {
	
	private ConditionCreator conditionCreator = new ConditionCreator();
	private OperationDescriptorCreator operationDescriptorCreator = new OperationDescriptorCreator();
	
	public OperationNode createOperationNodeWithConditions(String[] triggers) {
		OperationDescriptor descriptor = operationDescriptorCreator.createBasicDummyOperationDescriptor();
		OperationNode node = new OperationNode(descriptor);
		for(String trigger : triggers)
		{
			ConditionNode condition = conditionCreator.createSimpleConditionWithTrigger(trigger);
			node.addCondition(condition);
		}
		return node;
	}

	public OperationNode createOperationNodeWithDummyDescriptor() {
		OperationDescriptor descriptor = operationDescriptorCreator.createBasicDummyOperationDescriptor();
		OperationNode opeartionNode = new OperationNode(descriptor);
		return opeartionNode;
	}
	
	public OperationNode createOperationNodeWithId(String id)
	{
		OperationDescriptor descriptor = operationDescriptorCreator.createBasicOperationDescriptorWithID(id);
		OperationNode operationNode = new OperationNode(descriptor);
		return operationNode;
	}
}
